package com.net.orders.service.impl;

import com.caikun.model.entity.OrderServiceDetail;
import com.caikun.model.vo.OrderServiceDetailVO;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.net.orders.mapper.OrderServiceMapper;

import com.net.orders.service.OrderServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * 订单所选服务表(OrderServiceDetail)表服务实现类
 *
 * @author makejava
 * @since 2025-07-17 11:12:43
 */
@Service("orderServiceService")
public class OrderServiceServiceImpl implements OrderServiceService {
    @Autowired
    private OrderServiceMapper orderServiceMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param orderId 主键
     * @return 实例对象
     */
    @Override
    public List<OrderServiceDetailVO> queryById(Integer orderId) {
        List<OrderServiceDetailVO> orderServiceDetailVOList = orderServiceMapper.queryById(orderId);

        return orderServiceDetailVOList;
    }

    /**
     * 分页查询
     * @param orderServiceDetail 筛选条件
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public Page<OrderServiceDetail> queryByPage(OrderServiceDetail orderServiceDetail, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize); // 开启分页
        List<OrderServiceDetail> orderServiceDetailList = this.orderServiceMapper.queryAllByLimit(orderServiceDetail); // 普通查询即可
        return (Page<OrderServiceDetail>) orderServiceDetailList; // PageHelper 会自动将列表包装为分页信息
    }

    /**
     * 新增数据
     *
     * @param orderServiceDetail 实例对象
     * @return 实例对象
     */
    @Override
    public OrderServiceDetail insert(OrderServiceDetail orderServiceDetail) {
        this.orderServiceMapper.insert(orderServiceDetail);
        return orderServiceDetail;
    }

    /**
     * 修改数据
     *
     * @param orderServiceDetail 实例对象
     * @return 实例对象
     */
    @Override
    public OrderServiceDetail update(OrderServiceDetail orderServiceDetail) {
        return null;
    }

    /**
     * 通过主键删除数据
     *
     * @param orderId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer orderId) {
        return this.orderServiceMapper.deleteById(orderId) > 0;
    }
}
